package com.ipet.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.ipet.common.utils.PageUtils;
import com.ipet.common.utils.R;
import com.ipet.modules.sys.entity.PetSickroomEntity;
import com.ipet.modules.sys.service.PetSickroomService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 住院管理
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-04-23 17:42:13
 */
@RestController
@RequestMapping("sys/petsickroom")
public class PetSickroomController {
    @Autowired
    private PetSickroomService petSickroomService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:petsickroom:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = petSickroomService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:petsickroom:info")
    public R info(@PathVariable("id") Integer id){
			PetSickroomEntity petSickroom = petSickroomService.selectById(id);

        return R.ok().put("petSickroom", petSickroom);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:petsickroom:save")
    public R save(@RequestBody PetSickroomEntity petSickroom){
        petSickroom.setCreateTime(new Date());
			petSickroomService.insert(petSickroom);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:petsickroom:update")
    public R update(@RequestBody PetSickroomEntity petSickroom){
			petSickroomService.updateById(petSickroom);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:petsickroom:delete")
    public R delete(@RequestBody Integer[] ids){
			petSickroomService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
